package top.toptimus.dto.sizeFit;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.toptimus.dto.measure.MeasureItemDTO;

/**
 * 成衣量体值
 */
@NoArgsConstructor
public class GarmentFitDTO extends SizeFitDTO {
    private static final Logger logger = LoggerFactory.getLogger(GarmentFitDTO.class);
    @Getter
    private double inValue;
    @Getter
    private double outValue;

    public GarmentFitDTO(
            String itemCd,
            String itemValue,
            String itemNameCn,
            double itemFitValue,
            String fitCd,
            String sizeCd,
            double inValue,
            double outValue
    ) {
        super(itemCd, itemValue, itemNameCn, itemFitValue, fitCd, sizeCd);
        this.inValue = inValue;
        this.outValue = outValue;
    }

    public GarmentFitDTO(MeasureItemDTO measureItemDTO) {
        super(
                measureItemDTO.getItemCd(),
                measureItemDTO.getItemValue(),
                measureItemDTO.getItemNameCn(),
                measureItemDTO.getItemFitValue()
        );
        logger.info(
                JSON.toJSONString(measureItemDTO)
        );
        try {
            this.inValue = measureItemDTO.getInValue();
        } catch (Exception ignored) {
        }
        try {
            this.outValue = measureItemDTO.getOutValue();
        } catch (Exception ignored) {
        }
    }
}
